package com.itheima.servcie;

import cn.hutool.core.convert.Convert;
import com.itheima.bean.CodeBean;
import com.itheima.dbservice.SettingServiceApi;
import com.itheima.utils.ThreadLocalUtil;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SettingService {
    @DubboReference
    private SettingServiceApi settingServiceApi;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /*
    通知设置
     */
    public ResponseEntity settingNotice(Map<String,Boolean> map) {
        //1.获取id
        Long uid = Convert.toLong(stringRedisTemplate.opsForValue().get(CodeBean.ID));
//        Long uid  = ThreadLocalUtil.getId();
        //2.调用api执行操作
        settingServiceApi.settingNotice(uid,map);
        //3.返回
        return ResponseEntity.ok("设置完成!");
    }
}
